<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>函数的定义与调用</title>
</head>
<body>
    <script> 
        function getSum(n){
            if( n < 1){
            return 0;
            }
            return n+ getSum(n-1);
        } 
        document.write( '1到100个数相加和是:'+getSum(100));
        /* for(var i =1; i<= 100; i++){
            sum += i; 
        }*/
    </script>
</body>
</html>